class Solution80 {
    public int removeDuplicates(int[] nums) {
         if(nums.length <= 2) return nums.length ;
         int len = 0 ; 
         int i = 1 , j = 2 ; 
         while(i < nums.length  && j < nums.length){
           if(nums[j] != nums[i] || (nums[j]==nums[i] && nums[i]!=nums[i-1])){
              nums[++i] = nums[j];
           }   
           j ++ ;
         }

         return i+1 ; 
    
    }
}